<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Medium
  </div>
  <div>
   <h1 class="question_title">
    477. Total Hamming Distance
   </h1>
   <p>
    The
    <a href="https://en.wikipedia.org/wiki/Hamming_distance" target="_blank">
     Hamming distance
    </a>
    between two integers is the number of positions at which the corresponding bits are different.
   </p>
   <p>
    Now your job is to find the total Hamming distance between all pairs of the given numbers.
   </p>
   <p>
    <b>
     Example:
    </b>
    <br>
   </p>
   <pre>
<b>Input:</b> 4, 14, 2

<b>Output:</b> 6

<b>Explanation:</b> In binary representation, the 4 is 0100, 14 is 1110, and 2 is 0010 (just
showing the four bits relevant in this case). So the answer will be:
HammingDistance(4, 14) + HammingDistance(4, 2) + HammingDistance(14, 2) = 2 + 2 + 2 = 6.
</pre>
   <p>
    <b>
     Note:
    </b>
    <br>
   </p>
   <ol>
    <li>
     Elements of the given array are in the range of
     <code>
      0
     </code>
     to
     <code>
      10^9
     </code>
    </li>
    <li>
     Length of the array will not exceed
     <code>
      10^4
     </code>
     .
    </li>
   </ol>
  </div>
  <div>
   <h1 class="question_title">
    477. 汉明距离总和
   </h1>
   <p>
    两个整数的&nbsp;
    <a href="https://baike.baidu.com/item/%E6%B1%89%E6%98%8E%E8%B7%9D%E7%A6%BB/475174?fr=aladdin">
     汉明距离
    </a>
    指的是这两个数字的二进制数对应位不同的数量。
   </p>
   <p>
    计算一个数组中，任意两个数之间汉明距离的总和。
   </p>
   <p>
    <strong>
     示例:
    </strong>
   </p>
   <pre>
<strong>输入:</strong> 4, 14, 2

<strong>输出:</strong> 6

<strong>解释:</strong> 在二进制表示中，4表示为0100，14表示为1110，2表示为0010。（这样表示是为了体现后四位之间关系）
所以答案为：
HammingDistance(4, 14) + HammingDistance(4, 2) + HammingDistance(14, 2) = 2 + 2 + 2 = 6.
</pre>
   <p>
    <strong>
     注意:
    </strong>
   </p>
   <ol>
    <li>
     数组中元素的范围为从&nbsp;
     <code>
      0
     </code>
     到&nbsp;
     <code>
      10^9
     </code>
     。
    </li>
    <li>
     数组的长度不超过&nbsp;
     <code>
      10^4
     </code>
     。
    </li>
   </ol>
  </div>
 </body>
</html>